<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>评论管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css" th:href="@{/css/me.css}">
    <style type="text/css">
        .parent {
            width: 560px;
            /*background: antiquewhite;*/
        }

        .title {
            white-space: nowrap;
            width: 100%;
            overflow: hidden;
            color: #999aaa;
        }

        .content {
            word-wrap: break-word;
            word-break: break-all;
        }
        .name{
            color: black;font-weight: bolder
        }
        .bozhu{
            color: lightseagreen;
        }
    </style>

</head>
<body>

<!--导航栏-->
<nav th:replace="admin/_fragments::menu(4)" class="ui  inverted attached segment m-padded-tb-mini m-shadow-small">
    <div class="ui container">
        <div class="ui inverted secondary stackable menu">
            <h2 class="ui teal header item ">后台管理</h2>
            <a class="active m-item item m-mobile-hide"><i class="home icon"></i>博客</a>
            <a class="m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
            <a class="m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
            <a class="m-item item m-mobile-hide"><i class="tags icon"></i>评论</a>
            <div class="right menu">
                <div class="ui dropdown m-item m-mobile-hide item">
                    <div class="text">
                        <img src="https://picsum.photos/id/1005/100/100" alt="" class="ui avatar image">
                        定春
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>
<!--二级导航-->
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a href="#" th:href="@{/admin/comments/input}" class="item">新增</a>
            <a href="#" th:href="@{/admin/comments}" class="active teal item">列表</a>
        </div>
    </div>
</div>

<!--中间部分-->
<div class="m-container m-padded-tb-big">
    <div class="ui  container">
        <!--操作消息提示 th:unless条件为false才显示 if是true-->
        <div class="ui success message" th:unless="${#strings.isEmpty(commentMsg)}">
            <i class="close icon"></i>
            <div class="header">提示：</div>
            <p th:text="${commentMsg}">恭喜，操作成功！</p>
        </div>
        <!--博客表格-->
        <table class="ui celled compact teal table">
            <thead>
            <tr>
                <th></th>
                <th>内容</th>
                <th>评论时间</th>
                <th>层级</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="comment,iterStat: ${page.content}">
                <td th:text="${iterStat.count}">1</td>
                <td>
                    <div class="parent">
                        <a th:href="@{'/blog/'+${comment.blog.id}+'#comment-container'}" th:text="${comment.blog.title}" class="title" style="text-overflow: ellipsis">This is some
                            long text that will not fit in the box
                        </a>
                        <div>
                            <a th:classappend="${comment.adminComment}?'bozhu'"   th:text="${comment.nickname}" class="name">nihao:</a>
                            <a th:if="${comment.parentComment!=null}">
                                回复 [[${comment.parentComment.nickname}]]
                            </a>
                            :
                            <span th:text="${comment.content}"
                                  class="content">klaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span>
                        </div>
                    </div>
                </td>
                <td th:text="${#dates.format(comment.createTime,'yyyy-MM-dd HH:mm')}">评论时间</td>
                <!--                <td th:text="${comment.nickname}">用户名</td>-->
                <!--                <td th:text="${comment.content}">内容</td>-->
                <!--                <td th:text="${comment.blog.title}">文章标题</td>-->
                <td  th:text="${comment.parentComment == null?'一级':'二级'}">层级</td>
                <td>
                    <a href="#" th:href="@{/admin/comments/{id}/input(id=${comment.id})}"
                       class="ui mini teal button m-text">编辑</a>
                    <a href="#" th:href="@{/admin/comments/{id}/delete(id=${comment.id})}"
                       class="ui mini red  button m-text">删除</a>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <th colspan="6">
                    <!-- th:if="${page.totalPages}>1"-->
                    <div class="ui mini pagination menu">
                        <!--th:unless 除非...，否则执行, 如果不是...执行-->
                        <a th:href="@{/admin/comments(page=${page.number}-1)}" class="item"
                           th:unless="${page.first}">上一页</a>
                        <span class="ui item">
                              <a th:text="${page.number+1}"></a>/<a th:text="${page.totalPages}"></a>
                        </span>
                        <a th:href="@{/admin/comments(page=${page.number}+1)}" class="item"
                           th:unless="${page.last}">下一页</a>
                    </div>

                    <span class="ui  m-text-spaced">
                        &nbsp;  共<a th:text="${page.totalElements}"></a>条评论
                    </span>
                    <a href="#" th:href="@{/admin/comments/input}" class="ui mini right floated teal  button">新增</a>
                </th>
            </tr>
            </tfoot>
        </table>


    </div>
</div>

<br>
<br>

<!--底部-->
<footer th:replace="_fragments::footer" class="ui inverted vertical segment m-padded-tb-massive">
    <div class="ui center aligned  container">
        <div class="ui inverted divided stackable grid">
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../../static/images/wechat.jpg" class="ui rounded image" alt="" style="width: 110px">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">最新博客</h4>
                <div class="ui inverted link list m-text-thin m-text-spaced m-opacity-mini">
                    <a href="#" class="item">用户故事 User story</a>
                    <a href="#" class="item">用户故事 User story</a>
                    <a href="#" class="item">用户故事 User story</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">联系我</h4>
                <div class="ui inverted link list m-text-thin m-text-spaced m-opacity-mini">
                    <a href="#" class="item m-text-lined">Email: xingzq.dc@foxmail.com</a>
                    <a href="#" class="item">QQ: 1961329303</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">定春</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mini">
                    这是我的个人博客，也是我第一个上线的项目，我未来职业规划是当一名Java开发工程师，并朝着架构师的目标努力前行！</p>
            </div>
        </div>
        <div class="ui inverted section divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright © 2021 - 2022 Dingchun Designed by Dingchun</p>
    </div>
</footer>


<!--/*/<th:block th:replace="admin/_fragments :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<!--/*/</th:block>/*/-->

<script>
    function deleteComment(){
        $('.mini.modal')
            .modal('show')
        ;
    }

    $('#newblog-container').load(/*[[@{/footer/newblog}]]*/"/footer/newblog");
    /*隐藏导航栏右上角图标（PC端时）*/
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });

    /*弹出下拉框*/
    $('.ui.dropdown').dropdown({
        on: 'hover'
    });


    //消息提示关闭初始化
    $('.message .close').on('click', function () {
        $(this).closest('.message').transition('fade');
    });


    //自定义操作提示消息三秒自动关闭，这样写不太好，每次刷新页面都会执行，少了非空判断
    var t = 3;

    function fun() {
        t--;
        if (t <= 0) {
            $('.message .close').closest('.message').transition('fade');
            clearInterval(timer);
        }
    }

    var timer = setInterval("fun()", 1000);

</script>
</body>
</html>